<!DOCTYPE html>
<html>

<head>
    <title>我的邀请</title>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1,user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/reset.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/flex.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/dropload.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/accounts-child.css">
    <script type="text/javascript" src="/resource/web/js/flexible.js"></script>
    <script type="text/javascript" src="/resource/web/js/jquery-1.11.1.min.js"></script>
</head>

<body>
    <div class="title">
        <p>我的邀请</p>
        <a href="#0" onclick="javascript :history.back(-1);"><img class="back" src="/resource/web/img/newhead/path_7_copy.png"></a>
    </div>
    <div class="yq-top-mod">
        <div class="yq-tit tcf-flex tcf-justify-center">
            <p class="yq-t1">我的邀请码<span>[ {{$invite['user_invite_code']}} ]</span></p>
            <p class="yq-t2">立即邀请</p>
        </div>
        <!-- 邀请数量 -->
        <div class="yq-num tcf-flex tcf-justify-justify">
            <p class="">已成功邀请<span>{{$invite['invite_count']}}</span>人</p>
            <p>已赚取奖励<span>{{$invite['invest_amount']}}</span>元</p>
        </div>
    </div>
    <!-- 邀请列表 -->
    <div class="yq-list contents" style="">
        <ul class="yql-tit tcf-flex tcf-justify-center">
            <li>邀请日期</li>
            <li>被邀请人</li>
            <li>投资状态</li>
        </ul>
        <!-- 此处是列表内容 -->
        <div class="listsa"></div>
    </div>

    <!-- 无邀请显示 -->
    <div class="mod-not3" >
        <p><img src="/resource/web/img/account/no_msg.png"></p>
    </div>
<script src="/resource/web/js/dropload.min.js"></script>
<script type="text/javascript">
    function getLocalTime(nS) {
        var dateStr=new Date(parseInt(nS) * 1000).toLocaleDateString();
        dateStr=dateStr.replace(/年|月/g, "/").replace(/日/g,"");
        var month = (new Date(dateStr)).getMonth() + 1;
        var year = (new Date(dateStr)).getFullYear();
        var date = (new Date(dateStr)).getDate();
        if (month < 10) {
            month = '0' + month;
        }
        if (date < 10) {
            date = '0' + date;
        }
        return year+"-"+month+"-"+date;
    }
    $(".yq-list").hide();
    $(function(){
        // 页数
        var page = 0;
        // 每页展示5个
        //var size = 10;
        // dropload
        $('.contents').dropload({
            scrollArea : window,
            loadDownFn : function(me){
                page++;
                var result = '';
                $.ajax({
                    type: 'GET',
                    processData: false,
                    url: '/Web/invite_ajax.html?page='+page,
                    dataType: 'json',
                    success: function(data){
                        var arrLen = data.data.info;
                        var arrlist = data.data.length;
                        console.log(arrLen);
                        console.log(arrlist);
                        if(arrLen.length > 0){
                            $(".mod-not3").hide();
                            $(".yq-list").show();
                            for(var i=0; i<arrLen.length; i++){
                                //console.log( arrlist[i] );
                                result +=   '<ul class="yql-con tcf-flex tcf-justify-center "><li>'+getLocalTime(arrLen[i].add_time)+'</li>'
                                        +   '<li>'+arrLen[i].user_name+'</li>'
                                        +   '<li>'+arrLen[i].status+'</li></ul>'
                            }
                            // 如果没有数据
                        }else{

                            // 锁定
                            me.lock();
                            // 无数据
                            me.noData();
                        }
                        $('.listsa').append(result);
                        me.resetload();
                        // 为了测试，延迟1秒加载
                        /*setTimeout(function(){
                         // 插入数据到页面，放到最后面
                         $('.lists').append(result);
                         // 每次数据插入，必须重置
                         me.resetload();
                         },1000);*/
                    },
                    error: function(xhr, type){
                        console.log('Ajax error!');
                        // 即使加载出错，也得重置
                        me.resetload();
                    }
                });
            }
        });
    });
</script>
</body>

</html>
